/***************************************************************
 * Copyright(C) 2024, HTDisplay. All Rights Reserved
 *
 * This file is part of the HtDisplaySDK Project.
 *
 * @file    :  GpioFactory.cpp
 *
 * @brief   :  GPIO的工厂类
 *
 * @author  :  郑满乐
 *
 * @date    :  2024-11-19
 ***************************************************************/

#include "GpioFactory.h"

GpioFactory::GpioFactory() {

}

BasicGpio *GpioFactory::createGpio(DIChannel channel) {
    switch (channel) {
#ifdef PRODUCT_MODEL_HTDAC101_R2100
    case GpioChannel::DI_CHANNEL_NUMBER_00:
        return new GpioController("/dev/gpio/DI-00");
    case GpioChannel::DI_CHANNEL_NUMBER_01:
        return new GpioController("/dev/gpio/DI-01");
    case GpioChannel::DI_CHANNEL_NUMBER_02:
        return new GpioController("/dev/gpio/DI-02");
    case GpioChannel::DI_CHANNEL_NUMBER_03:
        return new GpioController("/dev/gpio/DI-03");
    case GpioChannel::DI_CHANNEL_NUMBER_04:
        return new GpioController("/dev/gpio/DI-04");
    case GpioChannel::DI_CHANNEL_NUMBER_05:
        return new GpioController("/dev/gpio/DI-05");
    case GpioChannel::DI_CHANNEL_NUMBER_06:
        return new GpioController("/dev/gpio/DI-06");
    case GpioChannel::DI_CHANNEL_NUMBER_07:
        return new GpioController("/dev/gpio/DI-07");
    case GpioChannel::DI_CHANNEL_NUMBER_08:
        return new GpioController("/dev/gpio/DI-08");
    case GpioChannel::DI_CHANNEL_NUMBER_09:
        return new GpioController("/dev/gpio/DI-09");
    case GpioChannel::DI_CHANNEL_NUMBER_10:
        return new GpioController("/dev/gpio/DI-10");
    case GpioChannel::DI_CHANNEL_NUMBER_11:
        return new GpioController("/dev/gpio/DI-11");
    case GpioChannel::DI_CHANNEL_NUMBER_12:
        return new GpioController("/dev/gpio/DI-12");
    case GpioChannel::DI_CHANNEL_NUMBER_13:
        return new GpioController("/dev/gpio/DI-13");
    case GpioChannel::DI_CHANNEL_NUMBER_14:
        return new GpioController("/dev/gpio/DI-14");
    case GpioChannel::DI_CHANNEL_NUMBER_15:
        return new GpioController("/dev/gpio/DI-15");
    case GpioChannel::DO_CHANNEL_NUMBER_00:
        return new GpioController("/dev/gpio/DO-00");
    case GpioChannel::DO_CHANNEL_NUMBER_01:
        return new GpioController("/dev/gpio/DO-01");
    case GpioChannel::DO_CHANNEL_NUMBER_02:
        return new GpioController("/dev/gpio/DO-02");
    case GpioChannel::DO_CHANNEL_NUMBER_03:
        return new GpioController("/dev/gpio/DO-03");
    case GpioChannel::DO_CHANNEL_NUMBER_04:
        return new GpioController("/dev/gpio/DO-04");
    case GpioChannel::DO_CHANNEL_NUMBER_05:
        return new GpioController("/dev/gpio/DO-05");
    case GpioChannel::DO_CHANNEL_NUMBER_06:
        return new GpioController("/dev/gpio/DO-06");
    case GpioChannel::DO_CHANNEL_NUMBER_07:
        return new GpioController("/dev/gpio/DO-07");
    case GpioChannel::DO_CHANNEL_NUMBER_08:
        return new GpioController("/dev/gpio/DO-08");
    case GpioChannel::DO_CHANNEL_NUMBER_09:
        return new GpioController("/dev/gpio/DO-09");
    case GpioChannel::DO_CHANNEL_NUMBER_10:
        return new GpioController("/dev/gpio/DO-10");
    case GpioChannel::DO_CHANNEL_NUMBER_11:
        return new GpioController("/dev/gpio/DO-11");
#elif PRODUCT_MODEL_HTDAC070_C2300
    case GpioChannel::DI_CHANNEL_NUMBER_00:
        return new GpioController("/dev/gpio/DI-00");
    case GpioChannel::DI_CHANNEL_NUMBER_01:
        return new GpioController("/dev/gpio/DI-01");
    case GpioChannel::DI_CHANNEL_NUMBER_02:
        return new GpioController("/dev/gpio/DI-02");
    case GpioChannel::DI_CHANNEL_NUMBER_03:
        return new GpioController("/dev/gpio/DI-03");
    case GpioChannel::DO_CHANNEL_NUMBER_00:
        return new GpioController("/dev/gpio/DO-00");
    case GpioChannel::DO_CHANNEL_NUMBER_01:
        return new GpioController("/dev/gpio/DO-01");
    case GpioChannel::DO_CHANNEL_NUMBER_02:
        return new GpioController("/dev/gpio/DO-02");
    case GpioChannel::DO_CHANNEL_NUMBER_03:
        return new GpioController("/dev/gpio/DO-03");
#elif PRODUCT_MODEL_HT3568M_1000
    case GpioChannel::DI_CHANNEL_NUMBER_00:
        return new GpioController("/dev/gpio/DI-00");
    case GpioChannel::DI_CHANNEL_NUMBER_01:
        return new GpioController("/dev/gpio/DI-01");
    case GpioChannel::DI_CHANNEL_NUMBER_02:
        return new GpioController("/dev/gpio/DI-02");
    case GpioChannel::DI_CHANNEL_NUMBER_03:
        return new GpioController("/dev/gpio/DI-03");
    case GpioChannel::DI_CHANNEL_NUMBER_04:
        return new GpioController("/dev/gpio/DI-04");
    case GpioChannel::DI_CHANNEL_NUMBER_05:
        return new GpioController("/dev/gpio/DI-05");
    case GpioChannel::DI_CHANNEL_NUMBER_06:
        return new GpioController("/dev/gpio/DI-06");
    case GpioChannel::DI_CHANNEL_NUMBER_07:
        return new GpioController("/dev/gpio/DI-07");
    case GpioChannel::DI_CHANNEL_NUMBER_08:
        return new GpioController("/dev/gpio/DI-08");
    case GpioChannel::DI_CHANNEL_NUMBER_09:
        return new GpioController("/dev/gpio/DI-09");
    case GpioChannel::DI_CHANNEL_NUMBER_10:
        return new GpioController("/dev/gpio/DI-10");
    case GpioChannel::DI_CHANNEL_NUMBER_11:
        return new GpioController("/dev/gpio/DI-11");
    case GpioChannel::DI_CHANNEL_NUMBER_12:
        return new GpioController("/dev/gpio/DI-12");
    case GpioChannel::DI_CHANNEL_NUMBER_13:
        return new GpioController("/dev/gpio/DI-13");
    case GpioChannel::DI_CHANNEL_NUMBER_14:
        return new GpioController("/dev/gpio/DI-14");
    case GpioChannel::DI_CHANNEL_NUMBER_15:
        return new GpioController("/dev/gpio/DI-15");
    case GpioChannel::DI_CHANNEL_NUMBER_16:
        return new GpioController("/dev/gpio/DI-16");
    case GpioChannel::DI_CHANNEL_NUMBER_17:
        return new GpioController("/dev/gpio/DI-17");
    case GpioChannel::DI_CHANNEL_NUMBER_18:
        return new GpioController("/dev/gpio/DI-18");
    case GpioChannel::DI_CHANNEL_NUMBER_19:
        return new GpioController("/dev/gpio/DI-19");
    case GpioChannel::DI_CHANNEL_NUMBER_20:
        return new GpioController("/dev/gpio/DI-20");
    case GpioChannel::DI_CHANNEL_NUMBER_21:
        return new GpioController("/dev/gpio/DI-21");
    case GpioChannel::DI_CHANNEL_NUMBER_22:
        return new GpioController("/dev/gpio/DI-22");
    case GpioChannel::DI_CHANNEL_NUMBER_23:
        return new GpioController("/dev/gpio/DI-23");
    case GpioChannel::DI_CHANNEL_NUMBER_24:
        return new GpioController("/dev/gpio/DI-24");
    case GpioChannel::DO_CHANNEL_NUMBER_00:
        return new GpioController("/dev/gpio/DO-00");
    case GpioChannel::DO_CHANNEL_NUMBER_01:
        return new GpioController("/dev/gpio/DO-01");
    case GpioChannel::DO_CHANNEL_NUMBER_02:
        return new GpioController("/dev/gpio/DO-02");
    case GpioChannel::DO_CHANNEL_NUMBER_03:
        return new GpioController("/dev/gpio/DO-03");
    case GpioChannel::DO_CHANNEL_NUMBER_04:
        return new GpioController("/dev/gpio/DO-04");
    case GpioChannel::DO_CHANNEL_NUMBER_05:
        return new GpioController("/dev/gpio/DO-05");
    case GpioChannel::DO_CHANNEL_NUMBER_06:
        return new GpioController("/dev/gpio/DO-06");
    case GpioChannel::DO_CHANNEL_NUMBER_07:
        return new GpioController("/dev/gpio/DO-07");
    case GpioChannel::DO_CHANNEL_NUMBER_08:
        return new GpioController("/dev/gpio/DO-08");
    case GpioChannel::DO_CHANNEL_NUMBER_09:
        return new GpioController("/dev/gpio/DO-09");
    case GpioChannel::DO_CHANNEL_NUMBER_10:
        return new GpioController("/dev/gpio/DO-10");
    case GpioChannel::DO_CHANNEL_NUMBER_11:
        return new GpioController("/dev/gpio/DO-11");
#endif
    default:
        return nullptr;
    }
}

BasicGpio *GpioFactory::createDI(DIChannel channel) {
    switch (channel) {
    case DIChannel::DI_CHANNEL_NUMBER_00:
        return new GpioController("/dev/gpio/DI-00");
    case DIChannel::DI_CHANNEL_NUMBER_01:
        return new GpioController("/dev/gpio/DI-01");
    case DIChannel::DI_CHANNEL_NUMBER_02:
        return new GpioController("/dev/gpio/DI-02");
    case DIChannel::DI_CHANNEL_NUMBER_03:
        return new GpioController("/dev/gpio/DI-03");
    case DIChannel::DI_CHANNEL_NUMBER_04:
        return new GpioController("/dev/gpio/DI-04");
    case DIChannel::DI_CHANNEL_NUMBER_05:
        return new GpioController("/dev/gpio/DI-05");
    case DIChannel::DI_CHANNEL_NUMBER_06:
        return new GpioController("/dev/gpio/DI-06");
    case DIChannel::DI_CHANNEL_NUMBER_07:
        return new GpioController("/dev/gpio/DI-07");
    case DIChannel::DI_CHANNEL_NUMBER_08:
        return new GpioController("/dev/gpio/DI-08");
    case DIChannel::DI_CHANNEL_NUMBER_09:
        return new GpioController("/dev/gpio/DI-09");
    case DIChannel::DI_CHANNEL_NUMBER_10:
        return new GpioController("/dev/gpio/DI-10");
    case DIChannel::DI_CHANNEL_NUMBER_11:
        return new GpioController("/dev/gpio/DI-11");
    case DIChannel::DI_CHANNEL_NUMBER_12:
        return new GpioController("/dev/gpio/DI-12");
    case DIChannel::DI_CHANNEL_NUMBER_13:
        return new GpioController("/dev/gpio/DI-13");
    case DIChannel::DI_CHANNEL_NUMBER_14:
        return new GpioController("/dev/gpio/DI-14");
    case DIChannel::DI_CHANNEL_NUMBER_15:
        return new GpioController("/dev/gpio/DI-15");
    default:
        return nullptr;
    }
}
BasicGpio *GpioFactory::createDO(DOChannel channel) {
    switch (channel) {
    case DOChannel::DO_CHANNEL_NUMBER_00:
        return new GpioController("/dev/gpio/DO-00");
    case DOChannel::DO_CHANNEL_NUMBER_01:
        return new GpioController("/dev/gpio/DO-01");
    case DOChannel::DO_CHANNEL_NUMBER_02:
        return new GpioController("/dev/gpio/DO-02");
    case DOChannel::DO_CHANNEL_NUMBER_03:
        return new GpioController("/dev/gpio/DO-03");
    case DOChannel::DO_CHANNEL_NUMBER_04:
        return new GpioController("/dev/gpio/DO-04");
    case DOChannel::DO_CHANNEL_NUMBER_05:
        return new GpioController("/dev/gpio/DO-05");
    case DOChannel::DO_CHANNEL_NUMBER_06:
        return new GpioController("/dev/gpio/DO-06");
    case DOChannel::DO_CHANNEL_NUMBER_07:
        return new GpioController("/dev/gpio/DO-07");
    case DOChannel::DO_CHANNEL_NUMBER_08:
        return new GpioController("/dev/gpio/DO-08");
    case DOChannel::DO_CHANNEL_NUMBER_09:
        return new GpioController("/dev/gpio/DO-09");
    case DOChannel::DO_CHANNEL_NUMBER_10:
        return new GpioController("/dev/gpio/DO-10");
    case DOChannel::DO_CHANNEL_NUMBER_11:
        return new GpioController("/dev/gpio/DO-11");
    default:
        return nullptr;
    }
}
BasicGpio *GpioFactory::createGpio(int number, std::string direction) {
    return new GpioController(number, direction);
}
